import Mock from 'mockjs'

// 引入mockjs模块
Mock.mock('/api/goodslist', 'get', {
  status: 200,
  message: '获取商品列表成功',
  'data|5': [{
    // id: '@increment(1)', // 自增id
    // id: '@id', // 随机id
    'id|+1': 0,
    name: '@cword(2, 5)',
    price: '@integer(100, 1000)',
    count: '@integer(1, 100)',
    imgUrl: '@dataImage("200x200", "商品图片")'
  }]
})
// 添加商品
Mock.mock('/api/addgoods', 'post', (option) => {
  console.log(option.body)
  return Mock.mock({
    status: 200,
    message: '@cword(2, 5)'
  })
  // return {
  //   status: 200,
  //   message: '添加商品成功'
  // }
})
// 商品详情 包含 \api\goodsdetail
Mock.mock(/\/api\/goodsdetail/, 'get', {
  status: 200,
  message: '获取商品详情成功',
  data: {
    id: '@increment(1)', // 自增id
    name: '@cword(2, 5)',
    price: '@integer(100, 1000)',
    count: '@integer(1, 100)',
    imgUrl: '@dataImage("200x200", "商品图片")'
  }
})
